﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GSAClient
{
    class Result
    {
        private decimal elapsed_time;
        private String query;
        private int totalResults;
        private Dictionary<String, String> query_params = new Dictionary<String, String>();
        private List<Product> products = new List<Product>();
        private List<Facet> facets = new List<Facet>();
        private List<String> restricts = new List<String>();
        private List<String> spelling_suggestions = new List<String>();
        private List<Dictionary<String, String>> keymatches = new List<Dictionary<String, String>>();
        private List<OneBoxResult> oneboxresults = new List<OneBoxResult>();

        public static String KEYMATCH_TITLE = "title";
        public static String KEYMATCH_URL = "url";

        public void setElapsedTime(decimal elapsed_time)
        {
            this.elapsed_time = elapsed_time;
        }


        public bool has_keymatches()
        {
            if (keymatches.Count > 0)
                return true;
            return false;
        }

        public bool has_oneboxresults()
        {
            if (oneboxresults.Count > 0)
                return true;
            return false;
        }

        public void addOneBoxResult(OneBoxResult obr)
        {
            this.oneboxresults.Add(obr);
        }

        public List<OneBoxResult> getOneBoxResults()
        {
            return oneboxresults;
        }


        public void addKeyMatch(String title, String url)
        {
            Dictionary<String, String> hm_km = new Dictionary<String, String>();
            hm_km.Add(Result.KEYMATCH_TITLE, title);
            hm_km.Add(Result.KEYMATCH_URL, url);
            keymatches.Add(hm_km);
        }

        public List<Dictionary<String, String>> getKeyMatches()
        {
            return keymatches;
        }


        public bool has_spelling_suggestions()
        {
            if (spelling_suggestions.Count >0)
                return true;
            return false;
        }

        public void addSpellingSuggestion(String suggest)
        {
            this.spelling_suggestions.Add(suggest);
        }

        public List<String> getSpellingSuggestions()
        {
            return this.spelling_suggestions;
        }

        public void addQueryParam(String key, String value) 
        {
            query_params.Add(key, value);
        }

        public Dictionary<String, String> getQueryParams() 
        {
            return this.query_params;
        }

        public decimal getElapsedTime()
        {
            return this.elapsed_time;
        }

        public void addFacet(Facet f)
        {
            this.facets.Add(f);
        }

        public List<Facet> getFacets()
        {
            return this.facets;
        }

        public void setTotalResults(int totalResults)
        {
            this.totalResults = totalResults;
        }

        public void setQuery(String query)
        {
            this.query = query;
        }

        public String getQuery()
        {
            return this.query;
        }

        public int getTotalResults()
        {
            return this.totalResults;
        }

        public void addProduct(Product p) 
        {
            this.products.Add(p);
        }

        public List<Product> getProducts()
        {
            return products;
        }
        
        public void addRestrict(String s) 
        {
            this.restricts.Add(s);
        }

        public List<String> getRestricts()
        {
            return restricts;
        }        
        
    }
}
